package chapter06;

import java.util.concurrent.TimeUnit;

/**
 * @author chisheng
 * @since 2021-11-11
 */
public class ThreadGroupEnumerateThreadGroups {

    public static void main(String[] args) throws InterruptedException {
        ThreadGroup myThreadGroup01 = new ThreadGroup("myThreadGroup01");
        ThreadGroup myThreadGroup02 = new ThreadGroup(myThreadGroup01, "myThreadGroup02");

        TimeUnit.MILLISECONDS.sleep(2);
        ThreadGroup mainThreadGroup = Thread.currentThread().getThreadGroup();

        ThreadGroup[] list = new ThreadGroup[mainThreadGroup.activeGroupCount()];
        int recurseCount = mainThreadGroup.enumerate(list);
        System.out.println(recurseCount);

        recurseCount = mainThreadGroup.enumerate(list, false);
        System.out.println(recurseCount);
    }

}
